package com.wyh.service;

import com.wyh.entity.Student;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @Author wangyaohan
 * @Date 2021/9/26 10:06
 * @ClassName StudentService
 */
public interface StudentService extends MongoRepository<Student, Integer> {
    /**
     * 年龄大于等于 age>=?
     * @param age
     * @return
     */
    List<Student> findByAgeGreaterThanEqual(Integer age);

    /**
     * 年龄小于等于 ang<=?
     * @param age
     * @return
     */
    List<Student> findByAgeLessThanEqual(Integer age);

    /**
     * 模糊查询 + 分页
     * @param name
     * @param pageable
     * @return
     */
    List<Student> findByNameLike(String name, Pageable pageable);

    /**
     * 年龄区间 20-25，不包含20,25
     * @param age1
     * @param age2
     * @return
     */
    List<Student> findByAgeBetween(@Param("age1") Integer age1, @Param("age2")Integer age2);

    /**
     * 精确查询
     * @param code
     * @return
     */
    Student findByCodeEquals(String code);


 }

